package unit4;

import java.util.Date;

public class ParamTest {
	public static void main(String[] args) {
		/*
		 * Test1:Method can't modify numeric parameters
		 */
		System.out.println("Testing tripleValue:");
		double percent=10;
		System.out.println("Before:percent:"+percent);
		tripleValue(percent);
		System.out.println("After :percent ="+percent);
		
		/*
		 * Test2:Method can change the state of object parameters 
		 */
		
		System.out.println("\nTesting tripleSalary:");
		Employee harry=new Employee("harry", 50000, new Date());
		System.out.println("Before :salary="+harry.getSalary());
		tripleSalary(harry);
		System.out.println("After :salary="+harry.getSalary());
		
		/*
		 * Test3: Method can't attach new objects to object parameters
		 */
		System.out.println("\nTesting swap:");
		Employee a=new Employee("alice", 56456,new Date());
		Employee b=new Employee("Bob",89411, new Date());
		System.out.println("Before:a="+a.getName());
		System.out.println("Before:b="+b.getName());
		swap(a,b);
		System.out.println("After:a="+a.getName());
		System.out.println("After:b="+b.getName());
	}

	private static void swap(Employee a, Employee b) {
		// TODO Auto-generated method stub
		Employee temp=a;
		a=b;
		b=temp;
		System.out.println("End of method :a="+a.getName());
		System.out.println("End of method :b="+b.getName());
		
	}

	private static void tripleSalary(Employee harry) {
		// TODO Auto-generated method stub
		harry.raiseSalary(200);
		System.out.println("end of method :salary="+harry.getSalary());
	}

	private static void tripleValue(double percent) {
		// TODO Auto-generated method stub
		percent=3*percent;
		System.out.println("end of method ：percent"+percent);
	}
}
